﻿/// <reference path="../typings/jquery/jquery.d.ts" />
$(() =>
{
    var targetElem = $("[data-targetMain='true']");
    if (targetElem.length > 0) {
        var hash = location.hash.slice(1);
        var main = new PhotoBlogApp.MainVm(targetElem[0], hash);
        $.get('/root/reloadChache', () => { console.log('warm'); });
    }

    $(document).on('mousedown', 'img', function (e)
    {
        if (e.which === 3) {
            $(this).on('contextmenu', ev =>
            {
                ev.preventDefault();
            });
        };
    });

    var exist = false;
    var className = 'active-link';
    $('.intro_wrap__title__nav > li > a').each(function ()
    {
        var location = window.location.href.replace(window.location.hash, "");
        var link = this.href.replace(window.location.hash, "");
        var elemLink = $(this);

        if (location == link) {
            elemLink.addClass(className);
            exist = true;
        } else {
            elemLink.removeClass(className);
        }
    });

    if (!exist) {
        var firstLink = $('.intro_wrap__title__nav > li > a')
            .first();
        firstLink
            .addClass(className);
    }
});